import api from './index';

export interface Category {
  id: string;
  name: string;
  description?: string;
  parentId?: string;
  level: number;
  order: number;
  createdAt: string;
  updatedAt: string;
}

// 获取分类列表
export const getCategoryList = () => {
  return api.get<any, Category[]>('/categories');
};

// 获取分类详情
export const getCategoryDetail = (id: string) => {
  return api.get<any, Category>(`/categories/${id}`);
};

// 创建分类
export const createCategory = (data: Partial<Category>) => {
  return api.post<any, Category>('/categories', data);
};

// 更新分类
export const updateCategory = (id: string, data: Partial<Category>) => {
  return api.put<any, Category>(`/categories/${id}`, data);
};

// 删除分类
export const deleteCategory = (id: string) => {
  return api.delete<any, void>(`/categories/${id}`);
};